<?php
namespace app\index\controller;

use think\Controller;
use think\Session;

class Index extends Controller
{
    public function index()
    {
        return $this->fetch();
    }

    public function login()
    {
        if(input('role')==0)
        {
            $result=db('admin')->where('adminname',input('uname'))->where('adminpwd',input('password'))->find();
            if($result)
            {
                Session::set('adminid',$result['adminid']);
                $this->redirect('SuperAdmin/AdminController/index');
            }
            $this->error('登陆失败');
        }
        else
        {
            $result=db('clubs')->where('caccount',input('uname'))->where('cpwd',input('password'))->find();
            if($result)
            {
                Session::set('clubid',$result['cid']);
                $this->redirect('ClubAdmin/ClubController/index');
            }
            $this->error('登陆失败');
        }
        die();

    }
}
